package com.caesar.exer2;

/**
 * @author caesar
 * @date 2025/7/21
 * @Description:
 * @apiNote
 */
public class Tortoise extends  Thread{
    private static boolean flag = true;

    public static boolean isFlag() {
        return flag;
    }
    public void run() {
        long start = System.currentTimeMillis();
        for (int i = 1; i <= 30; i++) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("乌龟跑了" + i + "米");
            if(i == 10||i==20){
                System.out.println("乌龟休息了");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
        long end = System.currentTimeMillis();
        flag = false;
        System.out.println("乌龟用时："+(double)(end-start)/1000.0+"秒");
    }
}
